<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib uri="/WEB-INF/html.tld" prefix="html" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>

<c:url var="applicationAssetDetails" value="/application/applicationAssets" />

 
<div id="applicationAssets" ></div>
<script>


$(function () {
	var applicationId=$("input[name='application.applicationId']").val();
	 var colM = [
    { title: "SRNO", width: 100 , dataType: "integer",dataIndx:"assetId",editable:false},
    { title: "ASSET TYPE", dataType: "string", width: 100,dataIndx:"assetCode" ,editable:false},
    { title: "ASSET", dataType: "float", width: 100,dataIndx:"assetModel" ,editable:false},
	{ title: "MANUFACTURER", dataType: "string", width: "100",dataIndx:"manufacturer",editable:false },
	{ title: "NAME", dataType: "string", width: 100,dataIndx:"asseetName" ,editable:false},
	{ title: "YEAR", dataType: "integer", width: 100 ,dataIndx:"assetYear",editable:false},
	{ title: "PRICE", dataType: "float", width: 100 ,dataIndx:"assetPrice",editable:false}
	];
    var dataModel = {
        location: "remote",
        sorting: "remote",
        paging: "remote",
        dataType: "JSON",
        method: "GET",
        curPage: 1,
        rPP: 30,
        sortIndx: 0,
        sortDir: "up",
        rPPOptions: [30, 40, 50, 100, 500, 1000],
        getUrl: function () {
            var sortDir = (this.sortDir == "up") ? "asc" : "desc";
            var sort = ['applicationId', 'title', 'amount', 'status', 'fistName', 'lastName',
                 'creationDate'];
            return { url: "${applicationAssetDetails}", data: "cur_page=" + this.curPage + "&records_per_page=" + 
                this.rPP + "&sortBy=" + sort[this.sortIndx] + "&dir=" + sortDir+ "&id=" + applicationId };
        },
        getData: function (dataJSON) {
            //var data= 
            	console.log(dataJSON)
            return { curPage: dataJSON.curPage, totalRecords: dataJSON.totalRecords, data: dataJSON };                
        }
    }

    var grid1 = $("div#applicationAssets").pqGrid({ width: 900, height: 400,
        dataModel: dataModel,
        colModel: colM,
        title:"[Application List]",
        resizable: true,            
        columnBorders: true
        
    });
    //for details
    $.extend(colM[1], {
    render: function (ui) {
        var rowData = ui.rowData;
     
            return '<a href="javascript:showObjectDetaisl(\''+rowData.assetId+'\',\'financialGridView\');">' + rowData.assetCode+'</a>';
       
    }
  });
    //for edit
    $.extend(colM[0], {
  	  render: function (ui) {
  	      var rowData = ui.rowData;
  	   
  	          return '<a href="javascript:editObject(\''+rowData.assetId+'\',\'asset.assetId\');">' + rowData.assetId+'</a>';
  	     
  	  }
  	});
});
</script>
 